package com.innovation.chengzhangriji.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;

import com.innovation.chengzhangriji.R;

public class TimelineMilestoneView extends FrameLayout {

    private CuteTextView mTextMilestone;

    public TimelineMilestoneView(Context context) {
        super(context);
        init(context);
    }

    public TimelineMilestoneView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public TimelineMilestoneView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public void setMilestone(String milestone) {
        mTextMilestone.setText(milestone);
    }

    private void init(Context context) {
        float density = getResources().getDisplayMetrics().density;
        int padL = (int) (16 * density);
        int padR = (int) (16 * density);
        int padY = (int) (8 * density);
        int height = (int) (59 * density);
        setMinimumHeight(height);
        int paddingLeft = (int) (4 * density);
        setPadding(paddingLeft, 0, 0, 0);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.layout_timeline_milestone, this);
        mTextMilestone = (CuteTextView) findViewById(R.id.text_milestone);
        mTextMilestone.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_milestone_2));
        mTextMilestone.setPadding(padL, padY, padR, padY);
    }
}
